<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/commonJS.jsp" %>
<%@ include file="../common/commonLabel.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
int days = Integer.parseInt((String)request.getAttribute("days"));
String year = request.getAttribute("funddate")==null?(String)request.getAttribute("year"):((String)request.getAttribute("funddate")).split("-")[0];
String month = request.getAttribute("funddate")==null?(String)request.getAttribute("month"):((String)request.getAttribute("funddate")).split("-")[1];

%>

<HTML>
<HEAD>
<TITLE>进货管理</TITLE>
<META content="text/html;charset=UTF-8" http-equiv=Content-Type>
<style type="text/css">
/* 操作列的宽度 */
.boxtd{
	width: 18%;
}
</style>
<script type="text/javascript">
//添加产品信息
function DoManage(){
	doQueryMess("<%=path %>/fundmanage.action?operate=inspage","","500","180");
}
//添加产品信息
function DoUpd(nowdate){
	doQueryMess("<%=path %>/fundmanage.action?operate=updpagelist&nowdate="+nowdate,"","500","230");
}
function doDel(id){
	if(confirm("确认删除这条数据？")){
		document.all.pid.value = id;
		document.all.operate.value = "delinfo";
		document.forms[0].submit();
	}
}
function doDel(id){
	if(confirm("确认删除这条数据？")){
		document.all.pid.value = id;
		document.all.operate.value = "delinfo";
		document.forms[0].submit();
	}
}
function doRowsum(){
	var days = <%=days %>;
	var dsum = 0;
	for(var j=1;j<=days;j++){
		var day = document.all["day"+j];
		var dasum = 0;
		for(var i =0;i<day.length;i++){
			dasum += (day[i].value-0);
		}
		document.getElementById("daysum"+j).innerHTML = dasum;
		dsum += dasum;
	}
	document.getElementById("daysum").innerHTML = dsum;
}
</script>
</HEAD>
<BODY class="bg" onload="doRowsum()">
<form action="<%=path %>/fundmanage.action" method="post" name="myform">
<table width="99.5%" height="100%" border="0" cellpadding="0" cellspacing="0" >
	<tr>
		<td class="MainBody">
		<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          	<td class="MainBody_title"><hello:forValue type="title" /></td>
        </tr>
        <tr>
			<td class="MainBody_td">
			
			<table border="0" cellpadding="0" cellspacing="0" class="MainBody_fun_tree">
          		<tr>
	          	<td align="left"></td>
				<td align="right" >
					<input type="submit" class="btn4" value="查询信息">&nbsp;&nbsp;
					<input type="button" class="btn4" onclick="DoManage();" value="添加资金流水">
				</td>
				<td>&nbsp;&nbsp;
					<input type="hidden" name="operate" value="sel">
				</td>
				</tr>
			</table>
		<TABLE class="choose_table" border="0" cellpadding="0" cellspacing="0">
			<%-- 固定条件结构 --%>
			<TR>
				<TH width="20%">查询条件：</TH>
				<TD><div class="box01">
						<SPAN>当前年月：<input type="text" name="funddate" value="<c:choose><c:when test="${empty funddate }">${year }-${month }</c:when><c:otherwise>${funddate }</c:otherwise></c:choose>" onfocus="WdatePicker({dateFmt:'yyyy-MM',readOnly:true})" class="Wdate"></SPAN>
					</div>
				</TD>
			</TR>
		</TABLE>
		<%
		List info = (List)request.getAttribute("listinfo");//数据信息
		%>
		<%-- 列表信息 全局 --%>
		<table border="1"  cellpadding="0" cellspacing="0" bordercolor="#B5DFF8" class="MainBody_table">
			<tr align="center">
				<th width="8%" onclick="doOrder('fundflag')" style="cursor: pointer;">资金类别</th>
		<%
			for(int i=1;i<=days;i++){
		%>
				<th onclick="DoUpd('<%=year+"-"+month+"-"+(i<10?"0"+i:i) %>')"><%=i<10?"&nbsp;"+i:i %></th>
		<% 	}%>
				<th >总合计</th>
			</tr>
		<%if(info!=null){ 
			for(int i=0;i<info.size();i++){
				Map minfo = (Map)info.get(i);
		%>
			<tr align="center" onmouseover="this.style.backgroundColor='#EEF7FD';" onmouseout="this.style.backgroundColor='';">
		        <td ><%=minfo.get("fundflag")==null?"":minfo.get("fundflag") %></td>
		        <%
		        double sum = 0;
		        for(int j=1;j<=days;j++){
		        	double one = minfo.get("day"+j)==null?0:Double.parseDouble((String)minfo.get("day"+j));
		        	sum += one;
		        %>
		        <td ><%=one%><input type="hidden" name="<%="day"+j %>" value="<%=one%>"></td>
		        <%} %>
		        <td ><%=sum %></td>
		   	</tr>
		   
		<% 	} %>
			<tr align="center" onmouseover="this.style.backgroundColor='#EEF7FD';" onmouseout="this.style.backgroundColor='';">
	        <td >单天合计：</td>
	        <%
	        for(int j=1;j<=days;j++){
	        %>
	        <td id="<%="daysum"+j %>"></td>
	        <%} %>
	        <td id="daysum"></td>
	   	</tr>
		<%}%>
		<c:if test="${empty listinfo}">
			<tr>
				<td colspan="<%=days+2 %>" align="center">暂时没有您可以浏览的信息 </td>
			</tr>
		</c:if>
		</table>
		<c:if test="${!empty listinfo}">
		<div style="margin-left: 20px;">
			<hello:AllPage />
		</div>
		</c:if>
		</td>
    </tr>
   </table>
    </td>
  </tr>
 </table>
</form>
</BODY>
</HTML>
